import complex_query from '@dfeidao/atom-nodejs/db/complex-query';
import count from '@dfeidao/atom-nodejs/db/count';
import { IncomingHttpHeaders } from 'http';
import { productid, systemid } from '../../atom/config';
// 这里是模糊查询一
interface Message {
	filter: {
		pn: number,
		department_no: string,
		post_no: string,
		staff_name: string,
		call_out_time: number,
		createdate: number,
		is_resident: string
	};
}
export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
   const query = complex_query(action_id, session_id, systemid);
   const dt = await query
   .add_field('department_staff', 'cabinet_staff_no', 'cabinet_staff_no')
   .add_field('department_staff', 'staff_name', 'staff_name')
   .add_field('department_staff', 'staff_no', 'staff_no')
   .add_field('department_staff', 'sex', 'sex')
   .add_field('department_staff', 'post_name', 'post_name')
   .add_field('department_staff', 'staff_state', 'staff_state')
   .add_field('department_staff', 'deptname', 'deptname')
   .add_field('department_staff', 'createdate', 'createdate')
   .where_like('department_staff', 'staff_name', '%' + message.filter.staff_name + '%')
	.page(20, message.filter.pn)
	.exec();
	const { prepare, exec } = count(action_id, session_id, systemid);
	prepare('department_staff', { productid,staff_name:'%' + message.filter.staff_name + '%'});
	const [c] = await exec();
    return{dt,c};


}
